package com.mo.core.base.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.http.ResponseEntity;

public class ClientBaseController {

   
    public ResponseEntity<?> writeSuccessToClient(String msg,Map<String,Object> data){
    	Map<String,Object> map = new HashMap<String,Object>();
    	map.put("res", 1);
		map.put("msg", msg);
		map.put("data",data );
		return ResponseEntity.ok(map);
    	
	}
	public ResponseEntity<?> writeExceptionToClient(String stackTrace){
		Map<String,Object> map = new HashMap<String,Object>();
    	map.put("res", -1);
		map.put("msg", "系统异常");
		map.put("data",stackTrace );
		return ResponseEntity.ok(map);
	}
	public ResponseEntity<?> writeErrorToClient(String msg){
		Map<String,Object> map = new HashMap<String,Object>();
    	map.put("res", 0);
		map.put("msg", msg);
		return ResponseEntity.ok(map);
	}
	/*private void writeJson(HttpServletResponse response,String jsonStr){
		try {
			response.setContentType("text/json");
			response.setContentType("application/json");
			response.setCharacterEncoding("utf-8");
			response.getWriter().write(jsonStr);
			response.getWriter().flush();
			response.getWriter().close();
		} catch (IOException e) {
			log.error("网络异常", e);
		}
	}*/
    
}
